package org.jing.core.logger.slf4j;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jing.core.logger.itf.JingLoggerItf;
import org.jing.core.logger.itf.JingLoggerLevelItf;
import org.jing.core.util.StringUtil;

/**
 * Description: <br>
 *
 * @author bks <br>
 * @since 2021-08-16 <br>
 */
public class Logger implements JingLoggerItf {
    private final Log logger;

    Logger(String name) {
        logger = LogFactory.getLog(name);
    }

    Logger(Class<?> clazz) {
        logger = LogFactory.getLog(clazz);
    }

    Log getLogback() {
        return logger;
    }

    @Override public void all(Object object) {
        try {
            logger.trace(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void all(Throwable throwable) {
        try {
            logger.trace(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void all(String msg, Object... parameters) {
        try {
            logger.trace(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void all(Throwable throwable, String msg) {
        try {
            logger.trace(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void all(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.trace(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void trace(Object object) {
        try {
            logger.trace(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void trace(Throwable throwable) {
        try {
            logger.trace(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void trace(String msg, Object... parameters) {
        try {
            logger.trace(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void trace(Throwable throwable, String msg) {
        try {
            logger.trace(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void trace(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.trace(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void debug(Object object) {
        try {
            logger.debug(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void debug(Throwable throwable) {
        try {
            logger.debug(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void debug(String msg, Object... parameters) {
        try {
            logger.debug(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void debug(Throwable throwable, String msg) {
        try {
            logger.debug(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void debug(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.debug(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void info(Object object) {
        try {
            logger.info(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void info(Throwable throwable) {
        try {
            logger.info(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void info(String msg, Object... parameters) {
        try {
            logger.info(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void info(Throwable throwable, String msg) {
        try {
            logger.info(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void info(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.info(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void warn(Object object) {
        try {
            logger.warn(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void warn(Throwable throwable) {
        try {
            logger.warn(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void warn(String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void warn(Throwable throwable, String msg) {
        try {
            logger.warn(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void warn(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void imp(Object object) {
        try {
            logger.warn(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void imp(Throwable throwable) {
        try {
            logger.warn(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void imp(String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void imp(Throwable throwable, String msg) {
        try {
            logger.warn(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void imp(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void sql(Object object) {
        try {
            logger.warn(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void sql(Throwable throwable) {
        try {
            logger.warn(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void sql(String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void sql(Throwable throwable, String msg) {
        try {
            logger.warn(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void sql(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.warn(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void error(Object object) {
        try {
            logger.error(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void error(Throwable throwable) {
        try {
            logger.error(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void error(String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void error(Throwable throwable, String msg) {
        try {
            logger.error(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void error(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void fatal(Object object) {
        try {
            logger.error(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void fatal(Throwable throwable) {
        try {
            logger.error(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void fatal(String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void fatal(Throwable throwable, String msg) {
        try {
            logger.error(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void fatal(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void off(Object object) {
        try {
            logger.error(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void off(Throwable throwable) {
        try {
            logger.error(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void off(String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void off(Throwable throwable, String msg) {
        try {
            logger.error(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void off(Throwable throwable, String msg, Object... parameters) {
        try {
            logger.error(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void log(JingLoggerLevelItf level, Object object) {
        try {
            logger.debug(object);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void log(JingLoggerLevelItf level, Throwable throwable) {
        try {
            logger.debug(throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void log(JingLoggerLevelItf level, String msg, Object... parameters) {
        try {
            logger.debug(StringUtil.mixParameters(msg, parameters));
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void log(JingLoggerLevelItf level, Throwable throwable, String msg) {
        try {
            logger.debug(msg, throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }

    @Override public void log(JingLoggerLevelItf level, Throwable throwable, String msg, Object... parameters) {
        try {
            logger.debug(StringUtil.mixParameters(msg, parameters), throwable);
        }
        catch (Throwable t) {
            logger.error("logger frame doesn't work", t);
        }
    }
}
